package Objetos 
{
	import flash.display.MovieClip;
	import flash.events.Event;
	/**
	 * ...
	 * @author Jen
	 */
	public class Inimigo extends MovieClip
	{
		protected var NB_velocityY		:Number;
		protected var NB_velocityX		:Number;		
		protected var NB_gravity		:Number;
		protected var inimigoRangeX		:Number;
		protected var spawnX			:Number;
		
		
		public var UI_life				:int;
		
		public var BO_dead 				:Boolean;
		
		
		public function Inimigo(x:Number) 
		{
			spawnX = x;
			this.x = x;
			UI_life = 8;
			NB_gravity = 0.9;
			NB_velocityY = 0;
			NB_velocityY = 5;	
			NB_velocityX = 2;
		}
		
		public function update():void
		{			
			inimigoRangeX = this.x - spawnX;
			trace (inimigoRangeX, spawnX)
			
			this.y += NB_velocityY;
			NB_velocityY += NB_gravity;
			
			inimigoAI();
			
			this.x -= NB_velocityX;
			
		}
		
		public function menosLife():void
		{
			UI_life --;
			
			if (UI_life <= 0)
			{
				BO_dead = true;	
			}
		}
		
		
		
		public function set trocarVelocityY(b:Number):void
		{
			NB_velocityY = b;
		}
		
		public function get getVelocityY():Number
		{
			return this.NB_velocityY;
		}
		
		public function inimigoAI():void
		{
			
			if (Math.abs(inimigoRangeX) >= 50)
			{
				NB_velocityX *= -1;
				this.scaleX *= -1;
			}
			
			
		}
	}
}